package com.gpf.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.gpf.common.ShiroUtils;
import com.gpf.common.SysUserMenu;
import com.gpf.pojo.SysUser;
import com.gpf.server.SysLogServer;
import com.gpf.server.SysMenuService;

@RequestMapping("/")
@Controller
public class PageController {

	@Autowired
	private SysLogServer sysLogServer;
	@Autowired
	private SysMenuService sysMenuService;

	@RequestMapping("doLoginUI")
	public String doLoginUI(){
		return "login";
	}
	@RequestMapping("doIndexUI")
	public String doIndexUI(Model model) {
		SysUser user=ShiroUtils.getUser();
		model.addAttribute("username", user.getUsername());
		List<SysUserMenu> userMenus=sysMenuService.findUserMenusByUserId(user.getId());
		model.addAttribute("userMenus",userMenus);
		return "starter";
	}
	@RequestMapping("log/log_list")
	public String doLogUI() {
		return "sys/log_list";
	}
	@RequestMapping("doPageUI")
	public String doPageUI() {
		return "common/page";
	}
	@RequestMapping("menu/menu_list")
	public String doMenuUI() {
		return "sys/menu_list";
	}
	@RequestMapping("menu/menu_edit")
	public String doMenuEdit() {
		return "sys/menu_edit";
	}

	//rest风格
	@RequestMapping("{module}/{moduleUI}")
	public String doModuleUI(@PathVariable String moduleUI) {
		return "sys/"+moduleUI;
	}
}
